Skip to content

Eliminate n+1 queries in moderation tool #6552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025

Conversation

akatsoulas
Copy link
Collaborator

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request aims to eliminate n+1 queries in the moderation tool by caching hierarchical topic queries per product. Key changes include:

  • Building a set of unique products to avoid duplicate queries
  • Caching hierarchical topics for each unique product
  • Updating each object's available topics using the cache instead of querying directly

Reviewed Changes

File Description
kitsune/flagit/views.py Implements caching for hierarchical topics to reduce duplicate DB queries during content moderation

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

kitsune/flagit/views.py:242

  • Consider verifying that question.product exists before accessing its id to prevent potential AttributeError when question.product is None.
obj.available_topics = product_topics_cache.get(question.product.id, [])

@akatsoulas akatsoulas merged commit a0823d0 into mozilla:main Mar 11, 2025
2 checks passed
@akatsoulas akatsoulas deleted the moderation-nplusone branch March 11, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant